package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class ChannelController {

    @Autowired
    private WmChannelService wmChannelService;

    @GetMapping("/channels")
    public ResponseResult channelsList(){
        return wmChannelService.channelsList();
    }

    @PostMapping("/save")
    public ResponseResult insertChannel(@RequestBody WmChannel wmChannel){
        return wmChannelService.insertChannel(wmChannel);
    }

    //
    @PostMapping("list")
    public PageResponseResult selectChannel(@RequestBody ChannelDto dto){
        return wmChannelService.selectChannel(dto);
    }

    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody WmChannel wmChannel){
        return wmChannelService.updateChannel(wmChannel);
    }

    @GetMapping("/del/{id}")
    public ResponseResult deleteChannel(@PathVariable("id") Integer id){
        return wmChannelService.deleteChannel(id);
    }
}
